{if (($fans['status']==2 || ($theme['endtime']+432000) < TIMESTAMP) && $system['s']['isshare']==1) }
 <script>
{else}
{php echo $config['iswxshare']==0?$register_jssdk:"<script src='https://res.wx.qq.com/open/js/jweixin-1.3.2.js'></script>";}
    <script>
      var GLat;
      var GLng;
      var orderid  = 0;
      var orderno = '';
      var isflag = false;
      var shareData = {
          title: '{$sharetitle}',
          desc: '{$sharedesc}',
          imgUrl: '{$shareimgurl}',
          link: '{$shareurl}'
      };
        wx.ready(function () {
          {if $canshare == 0}
          wx.hideOptionMenu();
          {else}
          wx.showOptionMenu();
          {/if}
          
          {if $config['locationtype']==1 && $config['iscomm']==1}
              wx.getLocation({
                  type: 'gcj02', //wgs84 或 gcj02
                  success: function (res) {
                      GLat = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                      GLng = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                  },
                  fail: function (res) {
                      alert('拒绝授权获取地理位置，无法获得红包！请刷新后，同意再继续！');
                  }
              });
          {/if}
            wx.onMenuShareAppMessage({
                title: shareData.title,
                desc: shareData.desc,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                trigger: function (res) {
                },
                success: function (res) {
                    
                  setTimeout(function(){
                    dosharepyq(0);
                  }, 500);
                },
                cancel: function (res) {
                },
                fail: function (res) {
                }
            });

            wx.onMenuShareTimeline({
                title: shareData.title,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                success: function () {
                  setTimeout(function(){
                    dosharepyq(1);
                    {if $config['iscomm']==1 && $config['comm41'] > 0}
                      dosharehb(); 
                    {/if}
                    {if $config['iscomm']==1 && $system['fenxiao07'] > 0 }
                      doyaoyiyaohb(); 
                    {/if}
                  }, 500);
                },
                cancel: function () {
                }
            });
              
        });

        wx.error(function (res) {
        });
        
        {/if}
        function topayyukuan(){
          var num = -1;
          var status = $('#status').val();
          if(status == "0"){            
            ds.dialog({
              title : '&#25805;&#20316;&#25552;&#31034;',
              content : '&#27963;&#21160;&#23578;&#26410;&#24320;&#22987;&#21734;',
              yesText : '&#30830;&#23450;',
                timeout :2.5,
            });
            return false;
          }
          if(status == "2"){              
            ds.dialog({
              title : '&#25805;&#20316;&#25552;&#31034;',
              content : '&#27963;&#21160;&#24050;&#32463;&#32467;&#26463;&#21862;',
              yesText : '&#30830;&#23450;',
                timeout :2.5,
            });
            return false;
          }
              closescreen();
              tips("正在支付..."); 
              $.ajax({
               type:'POST',
                     dataType : "json",
               data:{yukuan:1},
               url:'/{php echo createMobileUrl("yxpay",array("op"=>"ready","themeid"=>$themeid,"recordid"=>$recordid,"workerid"=>$workerid,"fromuid"=>$fromuid,"fopenid"=>$fopenid));}',
               success:function(data){
                 var json = data.message;
                 console.log(json);
                 if(json.errcode == 0){
                             if(json.payway == 0){
                                 window.location.href = json.url;
                             }else{
                                 //tips(json.tid);
                                 util.pay({
                                     orderFee : json.fee,
                                     payMethod : 'wechat',
                                     orderTitle : json.title,
                                     orderTid : json.tid,
                                     module : '{$_P['m']}',
                                     success : function(result) {
                                         {if empty($config['payedurl'])}
                                         tips2('支付成功',window.location.href);
                                         {else}
                                         tips2('支付成功','{$config["payedurl"]}');
                                         {/if}
                                     },
                                     fail : function(result) {
                                         alert('fail : ' + result.message);
                                     },
                                     complete : function(result) {
                                         location.reload();
                                     }
                                 });
                             }
                  }else if(json.errcode == 110){
                  tips2(json.msg,json.url);
                  }else{   
                  tips2(json.msg,'/{php echo createMobileUrl("index",array("themeid"=>$themeid));}');
                  }
               }
             });
        }
        function topaynew(){

        var num = -1;
        var status = $('#status').val();
        if(status == "0"){            
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#27963;&#21160;&#23578;&#26410;&#24320;&#22987;&#21734;',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        }
        if(status == "2"){              
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#27963;&#21160;&#24050;&#32463;&#32467;&#26463;&#21862;',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        }
        {if (!empty($myworker) && empty($config['isworkerpay']))} 
        {if $config['isxianxia']==1}
        {php $xianxiatips = '&#44;&#22914;&#38656;&#24110;&#23458;&#25143;&#19979;&#21333;&#35831;&#29992;&#32447;&#19979;&#24405;&#20837;';}
        {/if}
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#21592;&#24037;&#19981;&#21487;&#20197;&#25253;&#21517;&#44;&#22914;&#38656;&#27979;&#35797;&#35831;&#29992;&#38750;&#21592;&#24037;&#24494;&#20449;{$xianxiatips}',
            yesText : '&#30830;&#23450;',
              timeout :500,
          });
          return false;
        {/if}

        {if $system['gift']==1}

              var prizes = [];
              $('.select_prize_id:checked').each(function(){
                  prizes.push($(this).val());
              });
              // 记录礼品数量信息
              var prizes_arr = [];
              prizes_arr[0] = {$config['gifttypeselect2']};
              prizes_arr[1] = {$config['gifttypeselect1']};

              if(prizes.length < 1){
                ds.dialog({
                   title : '&#25805;&#20316;&#25552;&#31034;',
                   content : '&#35831;&#36873;&#25321;{$config['address']}',
                   yesText : '&#30830;&#23450;',
                     timeout :2.5,
                });
                return false;
                }
              {if $config['typeid'] == 0}
                  if(prizes_arr[0] > 0){
                    if(prizes.length > prizes_arr[0]){
                      ds.dialog({
                        title : '&#25805;&#20316;&#25552;&#31034;',
                        content : '&#27492;&#27963;&#21160;&#26368;&#22810;&#21482;&#33021;&#36873;&#25321;' + prizes_arr[0] + '&#39033;',
                        yesText : '&#30830;&#23450;',
                          timeout :2.5,
                      });
                      return false;
                    }else if(prizes.length < prizes_arr[1]){
                      ds.dialog({
                        title : '&#25805;&#20316;&#25552;&#31034;',
                        content : '&#27492;&#27963;&#21160;&#26368;&#23569;&#38656;&#35201;&#36873;&#25321;' + prizes_arr[1] + '&#39033;',
                        yesText : '&#30830;&#23450;',
                          timeout :2.5,
                      });
                      return false;
                    }
                  }
              {/if}
              
        {/if}
              

        {if $isyixuan == true}             
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#23458;&#25143;&#27963;&#21160;&#36827;&#34892;&#20013;&#44;&#19981;&#21487;&#27979;&#35797;',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        {/if}

        {if $system['gift']==1}
          var address = prizes;
        {else}
          {if $config['addresstype'] == 2 }
            var address = $('#address option:selected').val();
          {else}
            var address = $("#address").val();
          {/if}
        {/if}

        {if $config['shopstype'] == 0 }
          var option = $('#shoptitle option:selected').val();
        {elseif $config['shopstype'] == 4 }
          var option=''; 
          $(".on").each(function(){ 
            option=option+ $(this).html()+'|';
          })
          option='{php echo empty($config['gudingoptions'])?'':implode("|",$config['gudingoptions'])."|";}'+option;
        {elseif $config['shopstype'] == 3 }
          var option=''; 
          $(".cur").each(function(){ 
            option=option+ $(this).html()+'|';
          })
          // option='{php echo empty($config['gudingoptions'])?'':implode("|",$config['gudingoptions'])."|";}'+option;
        {else}
          var option = $("#shoptitle").val();
        {/if}
        var jiagetype = $('#jiagetype option:selected').val();
        var code = $('#code option:selected').val();
        var datetime = $("#date_order").val();
        var xieyi = $("input[name='xieyi']:checkbox").attr('checked');

        var username = $('#regname_order').val();
        var mobile = $("#username_order").val();
        if(username.length == 0){
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#35831;&#36755;&#20837;{$config['nametext']}',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        }
        if(mobile.length != 11){
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#35831;&#36755;&#20837;&#49;&#49;&#20301;{$config['mobiletext']}',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        }
        {if !empty($config['address'])}
          if(address.length <=0){
            ds.dialog({
              title : '&#25805;&#20316;&#25552;&#31034;',
              content : '&#35831;&#36755;&#20837;{$config['address']}',
              yesText : '&#30830;&#23450;',
                timeout :2.5,
            });
            return false;
          }
        {/if}
        
        {if !empty($config['shops'])}
        // option!=undefined
        if(option.length <=0){
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#35831;&#36873;&#25321;{$config['shops']}',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        }
        {/if}
        {if $system['jiage']>0}
        if(jiagetype.length <=0 || jiagetype == '&#35831;&#36873;&#25321;'){
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#35831;&#36873;&#25321;{$config['duojiagetips']}',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        }
        {/if}
        
        var checkid = $("#check_type").val();
        if(checkid == undefined || checkid == 0){
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#35831;&#36873;&#25321;&#19968;&#31181;&#21442;&#19982;&#26041;&#24335;！',
            yesText : '&#30830;&#23450;',
            timeout :2.5,
          });
          return false;
        }else if(checkid == 1){
          var joinidv = 0;
        }else if(checkid == 4){
          var joinidv = 4;
        }else if(checkid == 3){
          var joinidv = 9;
        }else{
          var joinidv = 1;
        }

        {if !empty($config['datetime'])}
          if(datetime.length <=0){
            ds.dialog({
              title : '&#25805;&#20316;&#25552;&#31034;',
              content : '&#35831;&#36873;&#25321;{$config['datetime']}',
              yesText : '&#30830;&#23450;',
                timeout :2.5,
            });
            return false;
          }
        {/if}

              closescreen();
              {if !($config['joinfee']=='0.00' && $config['groupprice']=='0.00')}
              tips("正在支付..."); 
              {/if}
              $.ajax({
               type:'POST',
                     dataType : "json",
               data:{num:num,joinid:joinidv,username : username,mobile:mobile,address:address,option:option,jiagetype:jiagetype,code:code,datetime:datetime},
               url:'/{php echo createMobileUrl("yxpay",array("op"=>"ready","themeid"=>$themeid,"recordid"=>$recordid,"workerid"=>$workerid,"fromuid"=>$fromuid,"fopenid"=>$fopenid));}',
               success:function(data){
                 var json = data.message;
                 console.log(json);
                 if(json.errcode == 0){
                             if(json.payway == 0){
                                 window.location.href = json.url;
                             }else{
                                 //tips(json.tid);
                                 util.pay({
                                     orderFee : json.fee,
                                     payMethod : 'wechat',
                                     orderTitle : json.title,
                                     orderTid : json.tid,
                                     module : '{$_P['m']}',
                                     success : function(result) {
                                         {if empty($config['payedurl'])}
                                         tips2('支付成功',window.location.href);
                                         {else}
                                         tips2('支付成功','{$config["payedurl"]}');
                                         {/if}
                                     },
                                     fail : function(result) {
                                         alert('fail : ' + result.message);
                                     },
                                     complete : function(result) {
                                         location.reload();
                                     }
                                 });
                             }
                  }else if(json.errcode == 110){
                  tips2(json.msg,json.url);
                  }else{   
                  tips2(json.msg,'/{php echo createMobileUrl("index",array("themeid"=>$themeid));}');
                  }
               }
             });
           }
    </script>